// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import { fetch, post } from './util/http'
import '../src/util/htmlRem'
import  '../src/styles/reset.css'
import '../src/styles/common.css'

import  { ToastPlugin } from 'vux'
Vue.use(ToastPlugin);

import  { AlertPlugin } from 'vux'
Vue.use(AlertPlugin);

import  { LoadingPlugin } from 'vux'
Vue.use(LoadingPlugin);

import  { ConfirmPlugin } from 'vux'
Vue.use(ConfirmPlugin)

import NavTitle from './components/NavTitle'
Vue.use(NavTitle)

import Uploader from './components/uploader/index'
Vue.use(Uploader)

import { dateFormat } from 'vux'

Vue.filter('dateFormat', function (value) {
  if(value && value != null){
    return dateFormat(new Date(value), 'YYYY-MM-DD');
  }else{
    return " ";
  }

})
Vue.filter('dateFormat2', function (value) {
  if(value && value != null){
    return dateFormat(new Date(value), 'YYYY-MM-DD HH:mm:ss');
  }else{
    return " ";
  }

})

Vue.config.productionTip = false;


Vue.prototype.$post = post;
Vue.prototype.$get = fetch;

router.beforeEach(function (to, from, next) {
  store.commit('updateLoadingStatus', {isLoading: true});
  //必须要加next()
  next();

});

router.afterEach(function (to) {
  window.scrollTo(0, 1);
  store.commit('updateLoadingStatus', {isLoading: false});
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})

